
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using Andromeda.Global.Business;
using Andromeda.Global.Data.Db;
using Andromeda.Global.Common;
using ForgeIt.Dal.dbo.Validator;

  
namespace ForgeIt.Dal.dbo.Stub
{
	internal abstract class DBContactTypeStub : dboSchema
	{
		#region private fields

		/// <summary>
		/// (fieldname, datatype, ischangeable(!isidentity), isinsertable(!isidentity), isforeignkey, foreigntable
		/// </summary>

		protected readonly DbField foIdContactType = new DbField("IdContactType", DbType.Int32, true, true, false, false, false, "");

		protected readonly DbField foDescription = new DbField("Description", DbType.String, false, false, true, true, false, "");

        #endregion private fields

        #region constructors

        protected DBContactTypeStub()
		{
		}

		protected DBContactTypeStub(bool ignorethis, string foDescription)
		{

			this.foDescription.Value = foDescription;

		}
	
		#endregion constructors
    
		#region public properties
		
		public override DbConnector CleanEntity
		{
			get { return new DBContactType(); }
		}


		public int IdContactType
		{
			get { return ObjectConverter.ToInt32(foIdContactType.Value); }
		}

		public string Description
		{
			get { return ObjectConverter.ToString(foDescription.Value); }
			set { foDescription.Value = value; }
		}

  
		public override string TableName
		{
			get { return "ContactType"; }
		}




		    protected override ValidationModelBase Validator
		    {
			    get { return new DBContactTypeValidator(); }
		    }
		#endregion public properties
    
		#region enumerator

		/// <summary>
		/// This enumerator contains a list of all the fields of the datasource
		/// </summary>
		public enum FieldNames
		{
			IdContactType,
			Description,

		}

		#endregion enumerator
    
		#region generic field methods

		/// <summary>
		/// Validates if a given  field value is a DbNull
		/// </summary>
		/// <param name="fieldName">The field to validate</param>
		///<returns>true if is DbNull, false otherwise</returns>
		public bool IsDbNull(FieldNames fieldName)
		{
			switch (fieldName)
			{

				case FieldNames.IdContactType: return (foIdContactType.Value is DBNull);

				case FieldNames.Description: return (foDescription.Value is DBNull);

			}

			throw new InvalidDataException();
		}

		/// <summary>
		/// Sets the given field value to DbNull
		/// </summary>
		/// <param name="fieldName">The field to set</param>
		public void SetDbNull(FieldNames fieldName)
		{
			switch (fieldName)
			{

				case FieldNames.IdContactType:
					foIdContactType.Value = DBNull.Value; break;

				case FieldNames.Description:
					foDescription.Value = DBNull.Value; break;

			}
		}
		
		#endregion generic field methods
    
        #region static factories

		/// <summary>
		/// Creates a new DB object that can be added to the database as a new row
		/// </summary>
		/// <returns>The instance of the DB Object</returns>
		public static DBContactType NewRow
		{
			get { return new DBContactType(); }
		}

		/// <summary>
		/// Returns multiple rows from the Datasource by a given set of WHERE clause fields, only includes fields where value != null
		/// </summary>
		/// <example>List of fields to filter by, null to ignore field (null = all).</example>
		/// <returns>A collection with the filtered results. </returns>
		internal static IEnumerable<DBContactType> ListEntity(object foIdContactType, object foDescription)
		{
			DBContactType helper = new DBContactType();
			

			helper.foIdContactType.Value = foIdContactType;

			helper.foDescription.Value = foDescription;


			return helper.GetEntityInstancesList(helper.Fields.ToArray()).Cast<DBContactType>();
        }

		/// <summary>
		/// Returns multiple rows from the Datasource by a given set of WHERE clause fields, only includes fields where value != null
		/// </summary>
		/// <example>List of fields to filter by, null to ignore field (null = all).</example>
		/// <returns>A collection with the filtered results. </returns>
		internal static IEnumerable<DBContactType> ListEntity()
		{
			return new DBContactType().GetEntityInstancesList(new DbField[0]).Cast<DBContactType>();
        }

      		/// <summary>
		/// Returns a single row from the datasource by a given set of RUID strong-typed values
		/// </summary>
		/// <returns>The instance for this key or a new one if no match is found.</returns>
		internal static DBContactType GetEntity(int foIdContactType)
		{
			DBContactType helper = new DBContactType();

			helper.foIdContactType.Value = foIdContactType;

			helper = helper.GetEntityInstance(helper.Ruid) as DBContactType;
			
			return helper;
		}


		#endregion static factories
	}
}